<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
<meta name="format-detection" content="telephone=no">
    #parse("/h5/common/webWords.html")
<link rel="stylesheet" type="text/css" href="http://${staticHost}/css/medioadaption.css">
<link rel="stylesheet" type="text/css" href="http://${staticHost}/css/stcss.css">
<script type="text/javascript" src="http://${staticHost}/js/jquery.js"></script>
<script type="text/javascript" src="http://${staticHost}/js/continuingEducation.js"></script>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
        $("#submitForm").click(function(){
           
        	showLoading();
        	var fId = $.trim($("#fId").val());
        	var fMemberName = $.trim($("#fMemberName").val());
        	var fAge = $.trim($("#fAge").val());
        	var fPoliticalOutlook = $.trim($("#fPoliticalOutlook").val());
        	var fWorkingUnit = $.trim($("#fWorkingUnit").val());
        	var fContactPhone = $.trim($("#fContactPhone").val());
        	
        	if(fId == "" && (fMemberName !="" || fAge!="" || fPoliticalOutlook!="" 
        			|| fWorkingUnit != "" || fContactPhone != "")){
        		saveFamilyMemberInfo(fMemberName,'1',fAge,fPoliticalOutlook,fWorkingUnit,fContactPhone);
        	}else if(fId != ""){
        		updateFamilyMemberInfo(fId,fMemberName,fAge,fPoliticalOutlook,fWorkingUnit,fContactPhone);
        	}
        	
        	var mId = $.trim($("#mId").val());
        	var mMemberName = $.trim($("#mMemberName").val());
        	var mAge = $.trim($("#mAge").val());
        	var mPoliticalOutlook = $.trim($("#mPoliticalOutlook").val());
        	var mWorkingUnit = $.trim($("#mWorkingUnit").val());
        	var mContactPhone = $.trim($("#mContactPhone").val());
        	
        	if(mId == "" && (mMemberName !="" || mAge!="" || mPoliticalOutlook!="" 
        			|| mWorkingUnit != "" || mContactPhone != "")){
        		saveFamilyMemberInfo(mMemberName,'2',mAge,mPoliticalOutlook,mWorkingUnit,mContactPhone);
        	}else if(fId != ""){
        		updateFamilyMemberInfo(mId,mMemberName,mAge,mPoliticalOutlook,mWorkingUnit,mContactPhone);
        	}
        	
        	var wId = $.trim($("#wId").val());
        	var wMemberName = $.trim($("#wMemberName").val());
        	var wAge = $.trim($("#wAge").val());
        	var wPoliticalOutlook = $.trim($("#wPoliticalOutlook").val());
        	var wWorkingUnit = $.trim($("#wWorkingUnit").val());
        	var wContactPhone = $.trim($("#wContactPhone").val());
        	
        	if(wId == "" && (wMemberName !="" || wAge!="" || wPoliticalOutlook!="" 
        			|| wWorkingUnit != "" || wContactPhone != "")){
        		saveFamilyMemberInfo(wMemberName,'3',wAge,wPoliticalOutlook,wWorkingUnit,wContactPhone);
        	}else if(wId != ""){
        		updateFamilyMemberInfo(wId,wMemberName,wAge,wPoliticalOutlook,wWorkingUnit,wContactPhone);
        	}
        	
        	var cId = $.trim($("#cId").val());
        	var cMemberName = $.trim($("#cMemberName").val());
        	var cAge = $.trim($("#cAge").val());
        	var cPoliticalOutlook = $.trim($("#cPoliticalOutlook").val());
        	var cWorkingUnit = $.trim($("#cWorkingUnit").val());
        	var cContactPhone = $.trim($("#cContactPhone").val());
        	
        	if(cId == "" && (cMemberName !="" || cAge!="" || cPoliticalOutlook!="" 
        			|| cWorkingUnit != "" || cContactPhone != "")){
        		saveFamilyMemberInfo(cMemberName,'4',cAge,cPoliticalOutlook,cWorkingUnit,cContactPhone);
        	}else if(cId != ""){
        		updateFamilyMemberInfo(cId,cMemberName,cAge,cPoliticalOutlook,cWorkingUnit,cContactPhone);
        	}
        	
        	var studentId = $("#studentId").val();
        	$.ajax({
                type:'post',
                url:'${requestHost}/schoolroll/auth/familyInfo/check',
                contentType:'application/x-www-form-urlencoded; charset=utf-8',
                data:{
               	 studentId:studentId
                },
                success: function () {
        			window.location.href="/schoolroll/auth/typeIn";
                }
            });
        	
        });
        
        function saveFamilyMemberInfo(memberName, appellation, age, politicalOutlook, workingUnit, contactPhone){
        	 $.ajax({
                 type:'post',
                 url:'/schoolroll/auth/familyInfo/save',
                 contentType:'application/x-www-form-urlencoded; charset=utf-8',
                 data:{
                	 memberName:memberName,
                	 appellation:appellation,
                	 age:age,
                	 politicalOutlook:politicalOutlook,
                	 workingUnit:workingUnit,
                	 contactPhone:contactPhone
                 },
                 success: function (result) {
                	console.log(result);
                 }
             });
        }
        
		function updateFamilyMemberInfo(id, memberName, age, politicalOutlook, workingUnit, contactPhone){
			$.ajax({
                type:'post',
                url:'${requestHost}/schoolroll/auth/familyInfo/update',
                contentType:'application/x-www-form-urlencoded; charset=utf-8',
                data:{
               	 id:id,
               	 age:age,
               	 memberName:memberName,
               	 politicalOutlook:politicalOutlook,
               	 workingUnit:workingUnit,
               	 contactPhone:contactPhone
                },
                success: function (result) {
                	console.log(result);
                }
            });
        }
		
		function showLoading(){
		    document.getElementById("over").style.display = "block";
		    document.getElementById("layout").style.display = "block";
		}
		
		function hideLoading(){
		    document.getElementById("over").style.display = "none";
		    document.getElementById("layout").style.display = "none";
		}
        
    });
</script>
    <style type="text/css">
    	.editMood{
            color: #333;
        }
         .current a {
             font-size: 20px;
         }
 
         .over {
             display: none;
             position: absolute;
             top: 0;
             left: 0;
             width: 100%;
             height: 100%;
             background-color: #f5f5f5;
             opacity:0.5;
             z-index: 1000;
         }

        .layout {
            display: none;
            position: absolute;
            top: 40%;
            left: 40%;
            width: 20%;
            height: 20%;
            z-index: 1001;
            text-align:center;
        }
    </style>
</head>


<body style="background-color:#f8f8f8;">
<div id="over" class="over"></div>
<div id="layout" class="layout"><img src="http://${staticHost}/images/loading.gif" /></div>
<div class="dlny clear">
   <dl>
      <dt><a href="/edu/auth/toEditHeadprotrait"><img src="${headPortrait}"></a></dt>
      <dd>
          [${studentName}] <a href="/edu/auth/toEditStudentInfo" class="editMood">${mood}</a>
      </dd>
   </dl>
</div>

<div class="baobiao">
    <h5>家庭主要成员<b>（已婚学员可选择爱人、子女填写，未婚学员可选择父亲、母亲填写，务必填写正确的联系电话）</b></h5>
    <div class="baobiao_p">
       <table width="100%" border="1" cellspacing="0" cellpadding="0">
       <input type="hidden" id="studentId" value="$studentId" />
  <tr>
    <td width="12%">称谓</td>
    <td>姓名</td>
    <td width="6%">年龄</td>
    <td>政治面貌</td>
    <td>工作（学习）单位及职务</td>
    <td>联系电话</td>
  </tr>
  <tr>
    <td>父亲</td>
    	<input id="fId" type="hidden" value="#if (!$father.id) #else $father.id #end">
    <td><input id="fMemberName" type="text" value="#if (!$father.memberName) #else $father.memberName #end"></td>
    <td><input id="fAge" type="text" value="#if (!$father.age) #else $father.age #end"></td>
    <td><input id="fPoliticalOutlook" type="text" value="#if (!$father.politicalOutlook) #else $father.politicalOutlook #end"></td>
    <td><input id="fWorkingUnit" type="text" value="#if (!$father.workingUnit) #else $father.workingUnit #end"></td>
    <td><input id="fContactPhone" type="text" value="#if (!$father.contactPhone) #else $father.contactPhone #end"></td>
  </tr>
  <tr>
    <td>母亲</td>
    	<input id="mId" type="hidden" value="#if (!$mather.id) #else $mather.id #end">
    <td><input id="mMemberName" type="text" value="#if (!$mather.memberName) #else $mather.memberName #end"></td>
    <td><input id="mAge" type="text" value="#if (!$mather.age) #else $mather.age #end"></td>
    <td><input id="mPoliticalOutlook" type="text" value="#if (!$mather.politicalOutlook) #else $mather.politicalOutlook #end"></td>
    <td><input id="mWorkingUnit" type="text" value="#if (!$mather.workingUnit) #else $mather.workingUnit #end"></td>
    <td><input id="mContactPhone" type="text" value="#if (!$mather.contactPhone) #else $mather.contactPhone #end"></td>
  </tr>
  <tr>
    <td>爱人</td>
    	<input id="wId" type="hidden" value="#if (!$wife.id) #else $wife.id #end">
    <td><input id="wMemberName" type="text" value="#if (!$wife.memberName) #else $wife.memberName #end"></td>
    <td><input id="wAge" type="text" value="#if (!$wife.age) #else $wife.age #end"></td>
    <td><input id="wPoliticalOutlook" type="text" value="#if (!$wife.politicalOutlook) #else $wife.politicalOutlook #end"></td>
    <td><input id="wWorkingUnit" type="text" value="#if (!$wife.workingUnit) #else $wife.workingUnit #end"></td>
    <td><input id="wContactPhone" type="text" value="#if (!$wife.contactPhone) #else $wife.contactPhone #end"></td>
  </tr>
  <tr>
    <td>子女</td>
    <input id="cId" type="hidden" value="#if (!$child.id) #else $child.id #end">
    <td><input id="cMemberName" type="text" value="#if (!$child.memberName) #else $child.memberName #end"></td>
    <td><input id="cAge" type="text" value="#if (!$child.age) #else $child.age #end"></td>
    <td><input id="cPoliticalOutlook" type="text" value="#if (!$child.politicalOutlook) #else $child.politicalOutlook #end"></td>
    <td><input id="cWorkingUnit" type="text" value="#if (!$child.workingUnit) #else $child.workingUnit #end"></td>
    <td><input id="cContactPhone" type="text" value="#if (!$child.contactPhone) #else $child.contactPhone #end"></td>
  </tr>
</table>
    </div>
   <div class="md_dl"><input name="" id="submitForm" type="image" src="http://${staticHost}/images/tj01.jpg" style="width:290px; height:42px; border:none; margin-top:20px; margin-bottom:30px;" /></div>
</div>

<div class="holderdiv"></div>
<div class="fixdiv">
  <ul>               
    <li>
    	#if($ssi.universityFillStatus == 1 && $ssi.baseInfoFillStatus == 1 && $ssi.workExperienceFillStatus == 1 && $ssi.familyFillStatus == 1)
    		<a href="/internal/auth/myClass">
    	#else
    		<a href="javascript:void(0)" onclick="window.history.go(-1)">
    	#end
    	<img src="http://${staticHost}/images/foticon001.jpg"><span>返回</span></a></li>
    <li><a href="/edu/auth/modifyPwd"><img src="http://${staticHost}/images/foticon004.jpg"><span>重置密码</span></a></li>
	<li><a href="javascript:void(0)" onclick="loginOut()"><img src="http://${staticHost}/images/foticon003.jpg"><span>退出系统</span></a></li>
  </ul>
</div>

</body>
</html>